<?php
/**
 * Created by PhpStorm.
 * User: chenzhitao
 * Date: 2018/5/11
 * Time: 上午11:18
 */

namespace App\Busi\Traits;


use App\Models\CategoryCompany;

Trait CatgoryCompanyTrait
{

    public function getCompanyIdsByCategoryId($category_id){
        $where = [
            ['category_id','=',$category_id]
        ];
        $fields = ['company_id'];
        $data = CategoryCompany::where($where)->select($fields)->groupBy('company_id')->get();
        if($data->isEmpty()){
            return [];
        }
        return $data->toArray();
    }
}